<commit_before><?php
namespace DM\MovieApp\Controllers;

use Kahlan\Plugin\Stub;
use DM\MovieApp\Model\Movie;
use DM\MovieApp\Services\MovieAPI;
use \Phalcon\Mvc\Controller;

describe(MovieApi::class, function () {
    describe("->indexAction", function () {
        it("calls fetch movies", function (){
            $indexController_instance = new indexController();
            expect(count($indexController_instance->indexAction()))->toBeGreaterThan(0);
        });
    });

    describe("->getMoviesFromApi", function(){
        it("returns movies", function(){
            $indexController_instance = new indexController();
            expect(count($indexController_instance->getMoviesFromApi()))->toBeGreaterThan(2);
        });
    });
    given('controller',function(){
         $controller = Stub::create(['extends' => indexController::class]);
         return $controller;
    });
    given('list_of_movies', function () {
        $list_of_movies = array();
        $movie = new Movie;
        $movie->id = 12345;
        $list_of_movies[] = $movie;
        return $list_of_movies;
            });

    describe("->storeMovies", function(){
        it("findFirst returns empty if it doesnt exist", function(){
        });
        it("saves if findFirst returns empty", function(){
            expect(Movie::class)
                ->toReceive('save');
            Stub::on($this->controller)
                ->method('::getMoviesFromApi')
                ->andReturn(array());
            Stub::on(Movie::class)
                ->method('::findFirst')
                ->andReturn();
            $this->controller->storeMovies($this->list_of_movies);
        });
    });
});<commit_msg>added more spec stuff<commit_after><?php
namespace DM\MovieApp\Controllers;

use Kahlan\Plugin\Stub;
use DM\MovieApp\Model\Movie;
use DM\MovieApp\Services\MovieAPI;
use \Phalcon\Mvc\Controller;

describe(MovieApi::class, function () {
    beforeEach(function () {
            $this->controller = new indexController();
    });

    describe("->indexAction", function () {
        it("calls getMoviesFromApi", function (){
            expect($this->controller)
                ->toReceive('getMoviesFromApi');
        });
        it("calls storeMovies", function (){
            expect($this->controller)
                ->toReceive('storeMovies')
                ->with(array(1234));
        });
        it("calls sort", function (){
            expect($this->controller)
                ->toReceive('sort')
                ->with('alphabetical');
        });
    });

    describe("->getMoviesFromApi", function(){
        it("returns movies", function(){
            $indexController_instance = new indexController();
            expect(count($indexController_instance->getMoviesFromApi()))->toBeGreaterThan(2);
        });
    });

    given('list_of_movies', function () {
        $list_of_movies = array();
        $movie = new Movie;
        $movie->id = 12345;
        $list_of_movies[] = $movie;
        return $list_of_movies;
            });

    describe("->storeMovies", function(){
        it("saves if findFirst returns empty", function(){
            expect(Movie::class)
                ->toReceive('save');
            Stub::on($this->controller)
                ->method('::getMoviesFromApi')
                ->andReturn(array());
            Stub::on(Movie::class)
                ->method('::findFirst')
                ->andReturn();
            $this->controller->storeMovies($this->list_of_movies);
        });
    });
});



{'fraction_non_alphanumeric': 0.15866741953698477, 'fraction_numerical': 0.004799548277809147, 'mean_word_length': 2.2805555555555554, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '3489451', 'n_tokens_mistral': 1030, 'n_tokens_neox': 963, 'n_words': 154}