<commit_before><?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class CompaniesTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testRedirectIfNotLogged()
    {
    	// accessible only for logged user
        $this->assertTrue(true);
        // $this->visit('companies')
        // 	 ->seePageIs('auth/login');
    }

    public function testAccessIfLogged()
    {
        $this->assertTrue(true);

    	// $user = factory(App\User::class)->create();

     //    $this->actingAs($user)
     //         ->withSession(['foo' => 'bar'])
     //         ->visit('companies')
    	// 	 ->seePageIs('companies');
    }
    public function testAdminCanGetListOfCompaniesJson()
    {
        // $companies = factory(App\Company::class, 3)->make();
        // dd($companies->toArray());
        $company = factory(App\Company::class)->create();

        $this->get('/')
             ->see($company->name);
    }
    public function testAdminCanSeeListOfCompanies()
    {
        $this->visit('/')
             ->see('List of companies');
    	// Cache::shouldReceive('get')
     //                ->once()
     //                ->with('key')
     //                ->andReturn('value');

     //    $this->visit('/companies')->see('value');


    	// $this->visit('companies')
    	//      ->seePageIs('companies')
    	// 	 ->see('List of comapnies');
    }
    public function testNew()
    {
        $this->assertTrue(true);
        return;
        $this->post('/company', ['name' => 'Tierre'])
             ->seeJson([
                 'created' => true,
             ]);
    }
    public function testDelete()
    {
        $this->assertTrue(true);
        return;
        $company = \App\Company::first();
        if(is_null($company)) {
            $this->assertTrue(true);
            return;
        }
        $id = $company['id'];
        $this->delete('/company/'.$id)->seeJsonEquals([
                'success' => 1,
                'message' => '',
                'deleted' => true,
             ]);
    }

    public function testDeleteButtonExist()
    {
        $name = 'n-'.time();
        $this->visit('/')
             ->see('Add Company')
             ->type($name, 'name')
             ->press('Add Company')
             ->seeInDatabase('companies', ['name' => $name])
             ->seePageIs('/')
             ->see($name)
             ->see('Delete')
             ->press('Delete Company')
             ->seePageIs('/')
             //->dontSee($name);
             ;

    }
}<commit_msg>Add additional tests for CompaniesTest<commit_after><?php

use App\Company;

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class CompaniesTest extends TestCase
{
    use DatabaseTransactions;

    public function test_tasks_are_displayed_on_the_dashboard()
    {
        factory(Company::class)->create(['name' => 'Company 1']);
        factory(Company::class)->create(['name' => 'Company 2']);
        factory(Company::class)->create(['name' => 'Company 3']);

        $this->visit('/')
             ->see('Company 1')
             ->see('Company 2')
             ->see('Company 3');
    }


    public function test_tasks_can_be_created()
    {
        $this->visit('/')->dontSee('Company 1');

        $this->visit('/')
            ->type('Company 1', 'name')
            ->press('Add Company')
            ->see('Company 1');
    }


    public function test_long_tasks_cant_be_created()
    {
        $this->visit('/')
            ->type(str_random(300), 'name')
            ->press('Add Company')
            ->see('Whoops!');
    }
    
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testRedirectIfNotLogged()
    {
    	// accessible only for logged user
        $this->assertTrue(true);
        // $this->visit('companies')
        // 	 ->seePageIs('auth/login');
    }

    public function testAccessIfLogged()
    {
        $this->assertTrue(true);

    	// $user = factory(App\User::class)->create();

     //    $this->actingAs($user)
     //         ->withSession(['foo' => 'bar'])
     //         ->visit('companies')
    	// 	 ->seePageIs('companies');
    }
    public function testAdminCanGetListOfCompaniesJson()
    {
        // $companies = factory(App\Company::class, 3)->make();
        // dd($companies->toArray());
        $company = factory(App\Company::class)->create();

        $this->get('/')
             ->see($company->name);
    }
    public function testAdminCanSeeListOfCompanies()
    {
        $this->visit('/')
             ->see('List of companies');
    	// Cache::shouldReceive('get')
     //                ->once()
     //                ->with('key')
     //                ->andReturn('value');

     //    $this->visit('/companies')->see('value');


    	// $this->visit('companies')
    	//      ->seePageIs('companies')
    	// 	 ->see('List of comapnies');
    }
    public function testNew()
    {
        $this->assertTrue(true);
        return;
        $this->post('/company', ['name' => 'Tierre'])
             ->seeJson([
                 'created' => true,
             ]);
    }
    public function testDelete()
    {
        $this->assertTrue(true);
        return;
        $company = \App\Company::first();
        if(is_null($company)) {
            $this->assertTrue(true);
            return;
        }
        $id = $company['id'];
        $this->delete('/company/'.$id)->seeJsonEquals([
                'success' => 1,
                'message' => '',
                'deleted' => true,
             ]);
    }

    public function testDeleteButtonExist()
    {
        $name = 'n-'.time();
        $this->visit('/')
             ->see('Add Company')
             ->type($name, 'name')
             ->press('Add Company')
             ->seeInDatabase('companies', ['name' => $name])
             ->seePageIs('/')
             ->see($name)
             ->see('Delete')
             
             ->press('Delete Company')
             ->seePageIs('/')
             //->dontSee($name);
             ;

    }
}
{'fraction_non_alphanumeric': 0.18002212739054843, 'fraction_numerical': 0.002528844634107792, 'mean_word_length': 1.691620586984262, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 123, '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': '4518699', 'n_tokens_mistral': 1846, 'n_tokens_neox': 1793, 'n_words': 285}