Example #1
1
 public function testNetBlockListCommandWithValidFilter()
 {
     $exitCode = Artisan::call('netblock:list', ['--filter' => '192.168.1.0']);
     $this->assertEquals($exitCode, 0);
     $this->assertContains('ISP Business Internet', Artisan::output());
     $this->assertNotContains('Customer 1', Artisan::output());
 }
Example #2
1
 public function testWithInvalidFilter()
 {
     $this->initDB();
     $exitCode = Artisan::call('ticket:show', ['ticket' => 'xxx']);
     $this->assertEquals($exitCode, 0);
     $this->assertContains('No matching ticket was found.', Artisan::output());
 }
Example #3
0
 public function testNetBlockListCommandWithValidFilter()
 {
     $exitCode = Artisan::call('netblock:list', ["--filter" => "10.1.16.128"]);
     $this->assertEquals($exitCode, 0);
     $this->assertContains("Customer 6", Artisan::output());
     $this->assertNotContains("Global internet", Artisan::output());
 }
 /**
  * before each test runs
  * here we migrate if no migration and reset if migration already run
  * TODO: This is not working when Laravel5 transaction mode (cleanup=true in config) is activated, figure out why (eg error: no such table: users in routing/RegisterCest)
  *
  * @param TestEvent $e
  * @return bool
  */
 public function beforeTest(TestEvent $e)
 {
     // instantiate Codeception console output
     $output = new Output([]);
     // get laravel5 module
     $l5 = $this->getModule('Laravel5');
     // output error and die if transaction mode is active (this extension does not work with Laravel 5 transaction mode) TODO: figure out why
     if ($l5->config['cleanup']) {
         $output->writeln("\n" . "Please set Laravel5 Codeception module's cleanup to false (in tests/functional.suite.yml) before using NeilRussell6\\CodeceptionLaravel5Extensions\\ArtisanMigrateExtension." . "");
         die;
     }
     // get current migration status
     Artisan::call('migrate:status', ['--database' => $this->connection]);
     $status = Artisan::output();
     //var_dump($status);
     // ... if no migrations the run migrate
     if (str_contains($status, "No migrations found")) {
         Artisan::call('migrate', ['--database' => $this->connection]);
         //$result = Artisan::output();
         //var_dump($result);
     } else {
         Artisan::call('migrate:refresh', ['--database' => $this->connection]);
         //$result = Artisan::output();
         //var_dump($result);
     }
 }
Example #5
0
 public function testWithValidFilter()
 {
     $this->initDB();
     $exitCode = Artisan::call('user:show', ['user' => $this->user->id]);
     $this->assertEquals($exitCode, 0);
     $this->assertContains($this->user->first_name, Artisan::output());
 }
Example #6
0
 public function testNotFoundFilter()
 {
     $this->initDB();
     $exitCode = Artisan::call('contact:list', ['--filter' => 'xxx']);
     $this->assertEquals($exitCode, 0);
     $this->assertContains('No contact found for given filter.', Artisan::output());
 }
Example #7
0
 public function testSetSystemAccount()
 {
     $this->initDB();
     $exitCode = Artisan::call('account:edit', ['id' => $this->account->id, '--systemaccount' => true]);
     $this->assertEquals($exitCode, 0);
     $this->assertContains('The account has been updated', Artisan::output());
     $this->assertTrue((bool) Account::find($this->account->id)->systemaccount);
 }
Example #8
0
 public function testNetBlockListCommandWithValidFilter()
 {
     $exitCode = Artisan::call('role:list', ["--filter" => "Abuse"]);
     $this->assertEquals($exitCode, 0);
     $output = Artisan::output();
     $this->assertContains("Abuse", $output);
     $this->assertNotContains("System Administrator", $output);
 }
Example #9
0
 public function testNetBlockShowWithStartEndFilter()
 {
     $this->initDB();
     $ip = $this->netblock->last_ip;
     $exitCode = Artisan::call('netblock:show', ['netblock' => $ip]);
     $this->assertEquals($exitCode, 0);
     $this->assertContains($this->netblock->contact->name, Artisan::output());
 }
Example #10
0
 public function testFilter()
 {
     $exitCode = Artisan::call('collector:list', ['--filter' => 'Rbl']);
     $this->assertEquals($exitCode, 0);
     $output = Artisan::output();
     $this->assertContains('Rbl', $output);
     $this->assertNotContains('Snds', $output);
 }
Example #11
0
 public function testNetBlockListCommandWithValidFilter()
 {
     $exitCode = Artisan::call('user:list', ['--filter' => 'user']);
     $this->assertEquals($exitCode, 0);
     $output = Artisan::output();
     $this->assertContains('*****@*****.**', $output);
     $this->assertNotContains('*****@*****.**', $output);
 }
Example #12
0
 public function testEnabled()
 {
     $this->initDB();
     $exitCode = Artisan::call('role:edit', ['id' => $this->role->id, '--name' => 'some bogus value']);
     $this->assertEquals($exitCode, 0);
     $this->assertContains('The role has been updated', Artisan::output());
     $this->assertEquals(Role::find($this->role->id)->name, 'some bogus value');
 }
Example #13
0
 public function testJson()
 {
     $this->initDB();
     $exitCode = Artisan::call('ticket:list', ['--json' => 'true']);
     $this->assertEquals($exitCode, 0);
     json_decode(Artisan::output());
     $this->assertEquals(json_last_error(), JSON_ERROR_NONE);
 }
 public function testValidCreate()
 {
     $faker = Factory::create();
     $domainName = $faker->domainName;
     Artisan::call('domain:create', ['name' => $domainName, 'contact_id' => Contact::all()->first()->id]);
     $this->assertContains('The domain has been created', Artisan::output());
     Domain::where('name', $domainName)->forceDelete();
 }
Example #15
0
 public function testWithValidFilter()
 {
     $exitCode = Artisan::call('role:list', ['--filter' => 'Abuse']);
     $this->assertEquals($exitCode, 0);
     $output = Artisan::output();
     $this->assertContains('Abuse', $output);
     $this->assertNotContains('System Administrator', $output);
 }
 public function testCreateValid()
 {
     $brand = factory(Brand::class)->create();
     Artisan::call('account:create', ['name' => 'test_dummy', 'brand_id' => $brand->id]);
     $output = Artisan::output();
     $this->assertContains('The account has been created', $output);
     Account::where('name', 'test_dummy')->forceDelete();
     $brand->forceDelete();
 }
Example #17
0
 public function testChangeWithAutoPassword()
 {
     $this->initDB();
     $exitCode = Artisan::call('user:edit', ['user' => $this->dummy->id, '--autopassword' => 'some dummy value']);
     $this->assertEquals($exitCode, 0);
     $output = Artisan::output();
     $this->assertContains('The user has been updated', $output);
     $this->assertContains('Using auto generated password', $output);
 }
 public function testIfNoPasswordIsSuppliedPasswordIsGenerated()
 {
     $user = factory(User::class)->make();
     Artisan::call('user:create', ['--first_name' => $user->first_name, '--last_name' => $user->last_name, 'email' => $user->email, 'account' => 'Default', '--language' => $user->locale, '--disabled' => $user->disabled]);
     $output = Artisan::output();
     $this->assertUsers($user, $this->findUserWithOutput($output), $this->returnGeneratedPasswordWithOutput($output));
     $this->assertContains('Using auto generated password: '******'The user has been created', $output);
 }
Example #19
0
 public function testEnabled()
 {
     $exitCode = Artisan::call('domain:edit', ["--id" => "1", "--enabled" => "false"]);
     $this->assertEquals($exitCode, 0);
     $this->assertContains("Domain has been successfully updated", Artisan::output());
     /**
      * I use the seeder to re-initialize the table because Artisan:call is another instance of DB
      */
     $this->seed('DomainsTableSeeder');
 }
Example #20
0
 public function testEnabled()
 {
     $exitCode = Artisan::call('netblock:edit', ['id' => '1', '--enabled' => 'false']);
     $this->assertEquals($exitCode, 0);
     $this->assertContains('The netblock has been updated', Artisan::output());
     /*
      * I use the seeder to re-initialize the table because Artisan:call is another instance of DB
      */
     $this->seed('NetblocksTableSeeder');
 }
Example #21
0
 public function testCompanyName()
 {
     $this->assertEquals('JOHND', Contact::find(1)->reference);
     $exitCode = Artisan::call('contact:edit', ['id' => '1', '--reference' => 'New reference']);
     $this->assertEquals($exitCode, 0);
     $this->assertContains('The contact has been updated', Artisan::output());
     $contact = Contact::find(1);
     $this->assertEquals('New reference', $contact->reference);
     $contact->reference = 'JOHND';
     $contact->save();
 }
Example #22
0
 public function testCompanyName()
 {
     $this->assertEquals('AbuseIO', Brand::find(1)->company_name);
     $exitCode = Artisan::call('brand:edit', ['id' => '1', '--company_name' => 'New name 1']);
     $this->assertEquals($exitCode, 0);
     $this->assertContains('The brand has been updated', Artisan::output());
     $brand = Brand::find(1);
     $this->assertEquals('New name 1', $brand->company_name);
     $brand->company_name = 'AbuseIO';
     $brand->save();
 }
Example #23
0
 public function testEnabled()
 {
     $this->initDB();
     $this->assertFalse((bool) Note::find($this->noteViewed->id)->viewed);
     $exitCode = Artisan::call('note:edit', ['id' => $this->noteViewed->id, '--viewed' => 'true']);
     $this->assertEquals($exitCode, 0);
     $this->assertContains('The note has been updated', Artisan::output());
     /*
      * I use the seeder to re-initialize the table because Artisan:call is another instance of DB
      */
     $this->assertTrue((bool) Note::find($this->noteViewed->id)->viewed);
 }
Example #24
0
 /**
  * Rollback a table from database
  *
  * @return \Illuminate\Http\Response
  * @throws Exception
  */
 public function rollback()
 {
     try {
         if (!LaraScaffold::all()->count()) {
             throw new \Exception("Nothing to rollback");
         }
         $exitCode = Artisan::call('migrate:rollback');
     } catch (Exception $e) {
         return $e->getMessage();
     }
     Session::flash('status', Artisan::output());
     return redirect('scaffold');
 }
Example #25
0
 /**
  * @Then I should be warned that the user already exists
  */
 public function iShouldBeWarnedThatTheUserAlreadyExists()
 {
     PHPUnit_Framework_Assert::assertContains('User already exists: ' . $this->user_email, Artisan::output());
 }
Example #26
0
 public function testWithInvalidFilter()
 {
     $exitCode = Artisan::call('brand:show', ["brand" => "xxx"]);
     $this->assertEquals($exitCode, 0);
     $this->assertContains("No matching brand was found.", Artisan::output());
 }
Example #27
0
 /**
  * Test starting command.
  */
 public function testStartCommand()
 {
     $this->artisan('wampeer:router:start', ['--loop' => false]);
     $this->assertRegExp('/Start Thruway WAMP router/', Artisan::output());
 }
Example #28
0
 public function testInvalidId()
 {
     $exitCode = Artisan::call('brand:delete', ['id' => '1000']);
     $this->assertEquals($exitCode, 0);
     $this->assertContains("Unable to find brand", Artisan::output());
 }
 /**
  * Rollback a table from database
  *
  * @return \Illuminate\Http\Response
  */
 public function rollback()
 {
     try {
         $exitCode = Artisan::call('migrate:rollback');
     } catch (Exception $e) {
         return $e->getMessage();
     }
     Session::flash('status', Artisan::output());
     return redirect('scaffold');
 }
Example #30
0
 public function testWithInvalidIdFilter()
 {
     $exitCode = Artisan::call('domain:show', ['domain' => '1000']);
     $this->assertEquals($exitCode, 0);
     $this->assertContains('No matching domain was found.', Artisan::output());
 }