Esempio n. 1
0
                 $this->exectuted['it']++;
             });
             $this->it("an it", function () {
                 $this->exectuted['it']++;
             });
         });
         $reporters = Stub::create();
         expect($reporters)->toReceive('process')->with('start', ['total' => 2]);
         expect($reporters)->toReceiveNext('process')->with('suiteStart', Arg::toBeAnInstanceOf('kahlan\\Report'));
         expect($reporters)->toReceiveNext('process')->with('specStart', Arg::toBeAnInstanceOf('kahlan\\Report'));
         expect($reporters)->toReceiveNext('process')->with('skip', Arg::toBeAnInstanceOf('kahlan\\Report'));
         expect($reporters)->toReceiveNext('process')->with('specEnd', Arg::toBeAnInstanceOf('kahlan\\Report'));
         expect($reporters)->toReceiveNext('process')->with('specStart', Arg::toBeAnInstanceOf('kahlan\\Report'));
         expect($reporters)->toReceiveNext('process')->with('skip', Arg::toBeAnInstanceOf('kahlan\\Report'));
         expect($reporters)->toReceiveNext('process')->with('suiteEnd', Arg::toBeAnInstanceOf('kahlan\\Report'));
         expect($reporters)->toReceiveNext('process')->with('end', Arg::toBeAn('array'));
         $this->suite->run(['reporters' => $reporters]);
         expect($describe->exectuted)->toEqual(['it' => 0]);
         expect($this->suite->focused())->toBe(false);
         expect($this->suite->status())->toBe(0);
         expect($this->suite->passed())->toBe(true);
     });
 });
 describe("::hash()", function () {
     it("creates an hash from objects", function () {
         $instance = new stdClass();
         $hash1 = Suite::hash($instance);
         $hash2 = Suite::hash($instance);
         $hash3 = Suite::hash(new stdClass());
         expect($hash1)->toBe($hash2);
         expect($hash1)->not->toBe($hash3);
            $range = [Carbon::parse('-1 year')->startOfYear(), Carbon::parse('-1 year')->endOfYear()];
            $this->query->lastYear();
            expect($this->query)->toReceive('whereBetween')->with('created_at', Arg::toBeAn('array'));
            expect($this->query->getBindings())->toEqual($range);
        });
        it('->lastMonth()', function () {
            $range = [Carbon::parse('-1 month')->startOfMonth(), Carbon::parse('-1 month')->endOfMonth()];
            $this->query->lastMonth();
            expect($this->query)->toReceive('whereBetween')->with('created_at', Arg::toBeAn('array'));
            expect($this->query->getBindings())->toEqual($range);
        });
        it('->yesterday()', function () {
            $range = [Carbon::yesterday(), Carbon::yesterday()->endOfDay()];
            $this->query->yesterday();
            expect($this->query)->toReceive('whereBetween')->with('created_at', Arg::toBeAn('array'));
            expect($this->query->getBindings())->toEqual($range);
        });
        it('->lastHour()', function () {
            $range = [Carbon::parse('-1 hour')->minute(0)->second(0), Carbon::parse('-1 hour')->minute(59)->second(59)];
            $this->query->lastHour();
            expect($this->query)->toReceive('whereBetween')->with('created_at', Arg::toBeAn('array'));
            expect($this->query->getBindings())->toEqual($range);
        });
        it('->lastMinute()', function () {
            $range = [Carbon::parse('-1 minute')->second(0), Carbon::parse('-1 minute')->second(59)];
            $this->query->lastMinute();
            expect($this->query)->toReceive('whereBetween')->with('created_at', Arg::toBeAn('array'));
            expect($this->query->getBindings())->toEqual($range);
        });
    });
});