Something went wrong. Try again.
Perl game server for TLE Community
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051use lib '..','../../lib';use Test::More tests => 2;use Test::Deep;use 5.010;
use strict;use warnings;
use TestHelper;TestHelper->clear_all_test_empires;
# BUG it is possible to build ships when there are negative docks available
my $tester = TestHelper->new({ big_producer => 1 })->generate_test_empire->build_infrastructure;my $session_id = $tester->session->id;my $empire = $tester->empire;my $home = $empire->home_planet;
my $spaceport = $tester->build_building('Lacuna::DB::Result::Building::SpacePort', 1);my $shipyard = $tester->build_building('Lacuna::DB::Result::Building::Shipyard',5);
# Build a trade ministry so we can build dorysmy $trade = $tester->build_building('Lacuna::DB::Result::Building::Trade',1);
# build as many ships as the space port can hold
my @ships;for ( 0 .. 1 ) { my $dory = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->new({type=>'dory'}); $shipyard->build_ship($dory); push @ships, $dory;}
# now try to build a new shipmy $result = $tester->post('shipyard', 'build_ship', [$session_id, $shipyard->id, 'dory']);is($result->{error}{code}, 1009, 'Cannot build ships if there are zero docks available');
# build more than the space port can holdmy $dory = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->new({type=>'dory'});$shipyard->build_ship($dory);push @ships, $dory;
# now try to build a new ship$result = $tester->post('shipyard', 'build_ship', [$session_id, $shipyard->id, 'dory']);is($result->{error}{code}, 1009, 'Cannot build ships if there are negative docks available');
END { TestHelper->clear_all_test_empires;}