<commit_before><?php

namespace SimplyTestable\ApiBundle\Tests\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class TestsControllerTest extends BaseControllerJsonTestCase {

    public function testStartAction() {        
        $this->setupDatabase();
        
        $controllerName = 'SimplyTestable\ApiBundle\Controller\TestsController';
        $controller = $this->createController($controllerName);       
        /* @var $controller \SimplyTestable\ApiBundle\Controller\TestsController */        
        
        $response1 = $controller->startAction('http:\/\/one.example.com');
        $response1JsonObject = json_decode($response1->getContent());
        
        $response2 = $controller->startAction('http:\/\/two.example.com');
        $response2JsonObject = json_decode($response2->getContent());
        
        $response3 = $controller->startAction('http:\/\/one.example.com');
        $response3JsonObject = json_decode($response3->getContent());        

        $this->assertEquals(200, $response1->getStatusCode());
        $this->assertEquals(200, $response2->getStatusCode());
        $this->assertEquals(200, $response3->getStatusCode());
        $this->assertEquals(1, $response1JsonObject->job_id);
        $this->assertEquals(2, $response2JsonObject->job_id);
        $this->assertEquals(1, $response3JsonObject->job_id);
    }
    
    public function testStatusAction() {
        $controllerName = 'SimplyTestable\ApiBundle\Controller\TestsController';
        $controller = $this->createController($controllerName);
        /* @var $controller \SimplyTestable\ApiBundle\Controller\TestsController */
        
        $response = $controller->statusAction('http:\/\/example.com', 1);
        $responseJsonObject = json_decode($response->getContent());

        $this->assertEquals(200, $response->getStatusCode());

        $this->assertEquals('http:\/\/example.com', $responseJsonObject->site_root_url);
        $this->assertEquals(1, $responseJsonObject->test_id);
    }    
    
    public function testResultsAction() {
        $controllerName = 'SimplyTestable\ApiBundle\Controller\TestsController';
        $controller = $this->createController($controllerName);
        /* @var $controller \SimplyTestable\ApiBundle\Controller\TestsController */
        
        $response = $controller->resultsAction('http:\/\/example.com', 1);
        $responseJsonObject = json_decode($response->getContent());<commit_msg>TestsControllerTest::testStatusAction, now tests meaningful test scenario<commit_after><?php

namespace SimplyTestable\ApiBundle\Tests\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class TestsControllerTest extends BaseControllerJsonTestCase {

    public function testStartAction() {        
        $this->setupDatabase();
        
        $controllerName = 'SimplyTestable\ApiBundle\Controller\TestsController';
        $controller = $this->createController($controllerName);       
        /* @var $controller \SimplyTestable\ApiBundle\Controller\TestsController */        
        
        $response1 = $controller->startAction('http://one.example.com');
        $response1JsonObject = json_decode($response1->getContent());
        
        $response2 = $controller->startAction('http://two.example.com');
        $response2JsonObject = json_decode($response2->getContent());
        
        $response3 = $controller->startAction('http://one.example.com');
        $response3JsonObject = json_decode($response3->getContent());        

        $this->assertEquals(200, $response1->getStatusCode());
        $this->assertEquals(200, $response2->getStatusCode());
        $this->assertEquals(200, $response3->getStatusCode());
        
        $this->assertEquals(1, $response1JsonObject->id);
        $this->assertEquals('public', $response1JsonObject->user);
        $this->assertEquals('http://one.example.com/', $response1JsonObject->website);        
        $this->assertEquals('new', $response1JsonObject->state);
        
        $this->assertEquals(2, $response2JsonObject->id);
        $this->assertEquals('public', $response2JsonObject->user);
        $this->assertEquals('http://two.example.com/', $response2JsonObject->website);
        $this->assertEquals('new', $response2JsonObject->state);
        
        $this->assertTrue($response1 == $response3);
    }
    
    public function testStatusAction() {
        $controllerName = 'SimplyTestable\ApiBundle\Controller\TestsController';
        $controller = $this->createController($controllerName);
        /* @var $controller \SimplyTestable\ApiBundle\Controller\TestsController */
        
        $response = $controller->statusAction('http:\/\/example.com', 1);
        $responseJsonObject = json_decode($response->getContent());

        $this->assertEquals(200, $response->getStatusCode());

        $this->assertEquals('http:\/\/example.com', $responseJsonObject->site_root_url);
        $this->assertEquals(1, $responseJsonObject->test_id);
    }    
    
    public function testResultsAction() {
        $controllerName = 'SimplyTestable\ApiBundle\Controller\TestsController';
        $controller = $this->createController($controllerName);
        /* @var $controller \SimplyTestable\ApiBundle\Controller\TestsController */
        
        $response = $controller->resultsAction('http:\/\/example.com', 1);
        $responseJsonObject = json_decode($response->getContent());
{'fraction_non_alphanumeric': 0.1448237885462555, 'fraction_numerical': 0.013215859030837005, 'mean_word_length': 3.376706827309237, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 78, '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': '6615701', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1403, 'n_words': 176}