Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Refactor session tests#2492

Merged
michael-grunder merged 2 commits into
developfrom
refactor-session-tests
May 23, 2024
Merged

Refactor session tests#2492
michael-grunder merged 2 commits into
developfrom
refactor-session-tests

Conversation

@michael-grunder

@michael-grunder michael-grunder commented May 22, 2024

Copy link
Copy Markdown
Member
  • Update these external scripts to take formal arguments with getopt to make it more straightforward what each of the currently positional arguments are actually for.

  • Create small helper classes for invoking these external scripts. Instead of startSessionProcess that takes a dozen arguments all but three of which have defaults, we can use a construct like this:

$runner = $this->sessionRunner() 
    ->max_execution_time(300) 
    ->locking_enabled(true) 
    ->lock_wait_time(-1) 
    ->lock_expires(0) 
    ->data($data) 
    ->compression($name);

// Invokes startSession.php with above args.
$result = $runner->exec_fg();

// Invokes regenerateSessionId.php with above args
$new_id = $runner->regenerate_id();

// Invokes getSessionData.php for this session ID.
$data   = $runner->get_data();
  • Add a bit of logic to TestSuite to dump more information about the source of an assertion to make it easier to track down problems when we assert outside of a top level public test_* method.

  • Create a few new assertions like assertKeyExists and assertKeyMissing which will generate much nicer assertions as opposed to

$this->assertTrue($this->redis->exists($some_key)); 
  • If our externally spawned session scripts fail output the exact call that was made along with all arguments as well as the output that we received to make it easier to narrow down.

* Update these external scripts to take formal arguments with `getopt` to
  make it more straightforward what each of the currently positional
  arguments are actually for.

* Create small helper classes for invoking these external scripts.
  Instead of `startSessionProcess` that takes a dozen argument all but
  three of which have defaults, we can use a construct like this:

  ```php
  $runner = $this->sessionRunner()
      ->max_execution_time(300)
      ->locking_enabled(true)
      ->lock_wait_time(-1)
      ->lock_expires(0)
      ->data($data)
      ->compression($name);

  // Invokes startSession.php with above args.
  $result = $runner->exec_fg();

  // Invokes regenerateSessionId.php with above args
  $new_id = $runner->regenerate_id();

  // Invokes getSessionData.php for this session ID.
  $data = $runner->get_data();
  ```

* Add a bit of logic to TestSuite to dump more information about the
  source of an assertion to make it easier to track down problems when
  we assert outside of a top level public `test_*` method.

* Create a few new assertions like `assertKeyExists` and
  `assertKeyMissing` which will generate much nicer assertions as
  opposed to

```php
$this->assertTrue($this->redis->exists($some_key));
```

* If our externally spawned session scripts fail output the exact call
  that was made along with all arguments as well as the output that we
  received to make it easier to narrow down.
@michael-grunder michael-grunder force-pushed the refactor-session-tests branch from b9576e0 to b258610 Compare May 22, 2024 21:26

@yatsukhnenko yatsukhnenko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change naming from snake case to camel case in SessionHelper class?

@michael-grunder michael-grunder merged commit b88e72b into develop May 23, 2024
@michael-grunder michael-grunder deleted the refactor-session-tests branch May 23, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants