---
name: "Prophet::Test"
section: "3pm"
platform: "linux"
package: "libprophet-perl"
version: "0.743-1"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/Prophet::Test"
---

# Prophet::Test(3pm)

### set\_editor($code)

Sets the subroutine that Prophet should use instead of `"Prophet::CLI::Command::edit_text"` (as this routine invokes an interactive editor) to `$code`.

### set\_editor\_script SCRIPT

Sets the editor that Proc::InvokeEditor uses.

This should be a non-interactive script found in *t/scripts*.

### import\_extra($class, $args)

### in\_gladiator($code)

Run the given code using Devel::Gladiator.

### repo\_path\_for($username)

Returns a path on disk for where `$username`'s replica is stored.

### repo\_uri\_for($username)

Returns a file:// URI for `$USERNAME`'S replica (with the correct replica type prefix).

### replica\_uuid

Returns the UUID of the test replica.

### database\_uuid

Returns the UUID of the test database.

### replica\_last\_rev

Returns the sequence number of the last change in the test replica.

### as\_user($username, $coderef)

Run this code block as `$username`.  This routine sets up the `%ENV` hash so that when we go looking for a repository, we get the user's repo.

### replica\_uuid\_for($username)

Returns the UUID of the given user's test replica.

### database\_uuid\_for($username)

Returns the UUID of the given user's test database.

### ok\_added\_revisions( { CODE }, $numbers\_of\_new\_revisions, $msg)

Checks that the given code block adds the given number of changes to the test replica. `$msg` is optional and will be printed with the test if given.

### serialize\_conflict($conflict\_obj)

Returns a simple, serialized version of a Prophet::Conflict object suitable for comparison in tests.

The serialized version is a hash reference containing the following keys:\
     meta =\> { original\_source\_uuid =\> 'source\_replica\_uuid' }\
     records =\> { 'record\_uuid' =\>\
                    { change\_type =\> 'type',\
                      props =\> { propchange\_name =\> { source\_old =\> 'old\_val',\
                                                      source\_new =\> 'new\_val',\
                                                      target\_old =\> 'target\_val',\
                                                    }\
                               }\
                    },\
                  'another\_record\_uuid' =\>\
                    { change\_type =\> 'type',\
                      props =\> { propchange\_name =\> { source\_old =\> 'old\_val',\
                                                      source\_new =\> 'new\_val',\
                                                      target\_old =\> 'target\_val',\
                                                    }\
                               }\
                    },\
                }

### serialize\_changeset($changeset\_obj)

Returns a simple, serialized version of a Prophet::ChangeSet object suitable for comparison in tests (a hash).

### run\_command($command, @args)

Run the given command with (optionally) the given args using a new Prophet::CLI object. Returns the standard output of that command in scalar form or, in array context, the STDOUT in scalar form \*and\* the STDERR in scalar form.

Examples:

```
    run_command('create', '--type=Foo');
```

### load\_record($type, $uuid)

Loads and returns a record object for the record with the given type and uuid.

### as\_alice CODE, as\_bob CODE, as\_charlie CODE, as\_david CODE

Runs CODE as alice, bob, charlie or david.
