<?php

namespace Top100stars\Tests;

use Top100stars\Models\GitTop100;
use Top100stars\Models\TopNLanguage;
use Top100stars\Interfaces\IGitTop100CSV;
use PHPUnit\Framework\TestCase;

class TestCases extends TestCase
{
    /**
     * Get the top 2 of JavaScript
     */
    public function testTop2Javascript()
    {
        $gitTop100 = new GitTop100('github-ranking-2018-12-18.csv');
        $topNLanguage = new TopNLanguage($gitTop100);
        
        $results = $topNLanguage->getNLanguage(2, 'JavaScript')->getCSV();
        
        // Test 
        $this->assertEquals(2, count($results));
        $expected = unserialize('a:2:{i:0;a:11:{i:0;s:1:"1";i:1;s:13:"top-100-stars";i:2;s:12:"freeCodeCamp";i:3;s:6:"296554";i:4;s:5:"20629";i:5;s:10:"JavaScript";i:6;s:44:"https://github.com/freeCodeCamp/freeCodeCamp";i:7;s:12:"freeCodeCamp";i:8;s:4:"6572";i:9;s:20:"2018-12-18T12:16:12Z";i:10;s:126:"The https://www.freeCodeCamp.org open source codebase and curriculum. Learn to code for free together with millions of people.";}i:1;a:11:{i:0;s:1:"3";i:1;s:13:"top-100-stars";i:2;s:3:"vue";i:3;s:6:"122454";i:4;s:5:"17507";i:5;s:10:"JavaScript";i:6;s:28:"https://github.com/vuejs/vue";i:7;s:5:"vuejs";i:8;s:3:"233";i:9;s:20:"2018-12-18T07:38:59Z";i:10;s:92:"🖖 A progressive, incrementally-adoptable JavaScript framework for building UI on the web.";}}');
        $this->assertEquals($expected, $results);
    }
}