OpenGuides::Test(3pm)

πŸ“¦
version 0.84 Β· 3 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– OpenGuides::Test πŸ’–

okay bestie, so this is OpenGuides::Test, part of the 3pm manual pages (perl module docs, yk), and it's literally the helper module for testing OpenGuides apps. sit down, grab a boba, we're gonna go through it together πŸ§‹βœ¨


🌸 NAME 🌸

OpenGuides::Test β€” Methods to help test OpenGuides applications.

like. the name says it all fr fr πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So what does this thing actually do? It provides methods to help when you're writing tests for OpenGuides. That's the whole vibe.

It's distributed and installed as part of the OpenGuides project, so it is not intended for independent installation β€” you can't just grab it and go, it comes with the family 🫢

Heads up: this documentation is probably only useful to OpenGuides developers. If that's not you, no shade, but this page might not hit the same πŸ’€

✨ SYNOPSIS ✨

here's the whole thing in action, look at her go:

use OpenGuides;
use OpenGuides::Test;

OpenGuides::Test::refresh_db();

my $config = OpenGuides::Test->make_basic_config;
$config->default_language( "nl" );

my $guide = OpenGuides->new( config => $config );

OpenGuides::Test->write_data(
                              guide      => $guide,
                              node       => "Crabtree Tavern",
                              os_x       => 523465,
                              os_y       => 177490,
                              categories => "Pubs",
                            );

obsessed. truly iconic behaviour πŸ‘‘


πŸŽ€ METHODS πŸŽ€

🌈 make_basic_config

my $config = OpenGuides::Test->make_basic_config;
$config->default_language( "nl" );

This one makes you an OpenGuides::Config object with all the needed fields pre-filled. Like, it does the boring setup so you don't have to 😌

And then? You can mess with it as much as you like. Go off. Customize. It's yours now πŸ’–


πŸ“ write_data

my $config = OpenGuides::Test->make_basic_config;
my $guide = OpenGuides->new( config => $config );

OpenGuides::Test->write_data(
                              guide      => $guide,
                              node       => "Crabtree Tavern",
                              os_x       => 523465,
                              os_y       => 177490,
                              categories => "Pubs\r\nPub Food",
                            );

okay so this method calls the make_cgi_object method to make its CGI object β€” which means you can supply values for any key mentioned there. iykyk 🌟

You should supply them exactly as they would come from a CGI form. For example, lines in a textarea are separated by "\r\n". Not "\n". Not vibes. "\r\n". periodt πŸ’…

Here's the cute part: this method will automatically grab the checksum from the database, so even if the node already exists, your data will still be written. slay πŸ’«

But what if you don't want that behaviour? Say, if you're testing edit conflicts? Then pass in a true value to the omit_checksum parameter:

OpenGuides::Test->write_data(
                              guide         => $guide,
                              node          => "Crabtree Tavern",
                              omit_checksum => 1,
                            );

And if you want to grab the output instead? Pass a true value to return_output:

my $output = OpenGuides::Test->write_data(
                                            guide        => $guide,
                                            node         => "Crabtree Tavern",
                                            return_output => 1,
                                          );

Similarly β€” yes, similarly, stay with me β€” if you pass a true value to return_tt_vars, the return value will be the variables which would have been passed to the template for output:

my %vars = OpenGuides::Test->write_data(
                                            guide        => $guide,
                                            node         => "Crabtree Tavern",
                                            return_tt_vars => 1,
                                          );

three ways to get your data back. main character options only πŸ‘‘βœ¨


🧚 make_cgi_object

my $q = OpenGuides::Test->make_cgi_object;

You can supply values for the following keys, and bestie, I'm listing all of them because we don't skip:

  • "content"
  • "categories"
  • "locales"
  • "node_image"
  • "node_image_licence"
  • "node_image_copyright"
  • "node_image_url"
  • "phone"
  • "fax"
  • "website"
  • "hours_text"
  • "address"
  • "postcode"
  • "map_link"
  • "os_x"
  • "os_y"
  • "osie_x"
  • "osie_y"
  • "latitude"
  • "longitude"
  • "summary"
  • "username"
  • "comment"
  • "edit_type"

And you should supply them exactly as they would come from a CGI form β€” eg lines in a textarea are separated by "\r\n". Same rule as before, no cap 🫢


πŸ’œ refresh_db

Openguides::Test::refresh_db();

Note the lowercase g in Openguides there β€” that's literally how it's written, don't come for me, I'm just the messenger 😭

What does it do? It unlinks the existing SQLite database t/node.db and the Plucene/Lucy indexes. Then it creates a new SQLite database t/node.db.

out with the old, in with the new. a true fresh start moment 🌸✨


πŸ‘‘ AUTHOR πŸ‘‘

The OpenGuides Project (openguides-dev@lists.openguides.org)


Copyright (C) 2004-2013 The OpenGuides Project.  All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page, bestie πŸŽ€ this was OpenGuides::Test(3pm), documented as part of perl v5.32.0, dated 2021-01-30. go forth and test your OpenGuides apps, you absolute legend πŸ’…πŸ¦‹πŸ’–

πŸ“¦ where this page comes from